<template>
	<view class="subsidy-pages">
		<view class="subsidy-block">
			<view class="record-list" v-for="item in infolist" :key="item.id">
				<view class="name-item">
					<view class="time">{{item.year+"年"+item.month+"月大学生进企业补助申领"}}</view>
					<view class="status" v-if="item">
						<view class="subsidy-bubtton" v-if="item.applicationState === 1"
							@click="goApply('/page_other/subsidy/form-fields',{id:item.id,type:1})">
							待申领
						</view>
						<span v-if="item.applicationState === 2"
							@click="goApply('/page_other/subsidy/form-fields',{id:item.id,type:2})"
							style="color: blue;">待发放</span>
						<span v-if="item.applicationState === 3"
							@click="goApply('/page_other/subsidy/form-fields',{id:item.id,type:2})"
							style="color: chartreuse;">已发放</span>
						<span v-if="item.applicationState === 4"
							style="color: red;">已过期</span>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		subsidyApplicationList
	} from '@/api/subsidy.js'
	export default {
		data() {
			return {
				infolist: [],
				page: 1,
				limit: 10,
			}
		},
		methods: {
			goApply(url, params = {}) {
				uni.navigateTo({
					url,
					success: function(res) {
						// 将参数传递给目标页面
						res.eventChannel.emit('acceptDataFromOpenerPage', params);
					}
				})
			},
			getList() {
				subsidyApplicationList({
					page: this.page,
					limit: this.limit
				}).then((res) => {
					this.infolist = res.list ?? [];
				})
			},
		},
		onLoad() {
			this.getList()
		},
		onShow() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.subsidy-pages {
		overflow: hidden;
		min-height: 100vh;
		background-color: #F5F5F5;

		.subsidy-block {
			width: calc(100% - 60rpx);
			margin: 30rpx auto;

			.record-list {
				background-color: #FFFFFF;
				margin-bottom: 30rpx;
				padding: 30rpx;
				border-radius: 20rpx;

				.name-item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 30rpx;

					.time {
						color: #000000;
						font-family: Microsoft YaHei;
						font-size: 30rpx;
						font-weight: normal;
						line-height: 70rpx;
						letter-spacing: 0px;
						font-weight: bold;
					}

					.status {
						font-size: 28rpx;
						color: #FFFFFF;

						.subsidy-bubtton {
							border-radius: 50px;
							background: #0256ff;
							padding: 10rpx 20rpx;
						}
					}
				}
			}
		}
	}
</style>